-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
gh-116146: Add C-API to create module from spec and initfunc #139196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-116146: Add C-API to create module from spec and initfunc #139196
Conversation
f9cd705 to
4363e5a
Compare
encukou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable.
I'm proposing a replacement for Init functions in PEP-793, but that PEP adds PyModule_FromSlotsAndSpec and PyModule_Exec which should work for similar use cases.
Would it make sense to switch the spec & initfunc arguments to match that proposal?
I'm not sure if the word Builtin in the name is necessary -- is that to match the internal create_builtin? Would something like PyImport_LoadModuleFromInitfuncAndSpec work better?
Do you want to submit this to the C API WG?
I think it should be fine! Is the PEP already implemented on main?
Yes, I used it to reflect what it does internally.
Will do. Should we first decide whether to change this to match PEP 793, or go to the WP with options and get their input? |
No, it's not even accepted :)
Just go to the WG :) |
done :) capi-workgroup/decisions#77 |
- use `PyImport_CreateModuleFromInitfunc` for the new API - no need to introduce `create_builtin_ex` - update `create_builtin` and all callers - update exception message
4363e5a to
781a730
Compare
Co-authored-by: Kumar Aditya <[email protected]>
|
I left my suggestions as a PR: itamaro#27 |
* Test single-phase init as well; don't use private APIs in test * Doc update --------- Co-authored-by: Itamar Oren <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
…on under the free-threaded build
8f16533 to
1165950
Compare
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new function PyImport_CreateModuleFromInitfunc() should be documented in Doc/whatsnew/3.15.rst.
Misc/NEWS.d/next/C_API/2025-11-08-10-51-50.gh-issue-116146.pCmx6L.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Petr Viktorin <[email protected]> Co-authored-by: Kumar Aditya <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
fabafb5 to
fbfde0a
Compare
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the updates!
|
Congrats @itamaro! |
C-API WG decision: capi-workgroup/decisions#77